#ifndef CRCBLOCKS_H_
#define CRCBLOCKS_H_

#include <fstream>
#include <iostream>
#include <cstring>
#include <cstdlib>

using namespace std;

#include "../exception/InitializationException.h"

using namespace ::miniprojeto::excpetion;


namespace miniprojeto {
namespace Redundancy{

class CRCBlocks {
private:
	int number, blockSize;
	unsigned char* block;
	void setBlock (unsigned char* block, int bSize);
	unsigned short reminder;
public:
	static const int BLOCK_SIZE;
	CRCBlocks();
	CRCBlocks(unsigned char* block);
	CRCBlocks(unsigned char* block, int bSize, unsigned short reminder=0);
	~CRCBlocks();
	unsigned char* getBytes();
	void setNumber (int number);
	void setReminder(unsigned short reminder);
	unsigned short getReminer();
	int getNumber();
	int getBlockSize();
	unsigned short getReminder();
	bool writeFile (ofstream& out);
	bool readFile (ifstream& in); 
	
	/* sobrecarregar operadores é necessário pois a Lista_Cresc utiliza estes
	  operadores para classificar os blocks em ordem */
	bool operator<(CRCBlocks* b);
	bool operator>(CRCBlocks* b);
	bool operator<=(CRCBlocks* b);
	bool operator>=(CRCBlocks* b);
	bool operator==(CRCBlocks* b);
	
};

}
}

#endif /*CRCBLOCKS_H_*/
